package com.TheyChat.service.config.core.entity;

import com.TheyChat.service.config.core.exception.ResponseMessageErrorCodeEnum;

/**
 * @Author: victor.w.ye
 * @Date: 2021/2/20 15:35
 * @Copyright:
 * @Company: luban
 * @Version: 1.0.0
 **/
public class Result {

    public static <T> ResponseMessage<T> success() {
        return new ResponseMessage<>(ResponseMessageErrorCodeEnum.SUCCESS.getCode(), "", true);
    }

    public static <T> ResponseMessage<T> success(int code, T t) {
        return new ResponseMessage<>(code, "", true, t);
    }

    public static <T> ResponseMessage<T> success(int code, String message, T t) {
        return new ResponseMessage<>(code, message, true, t);
    }

    public static <T> ResponseMessage<T> success(T t) {
        return new ResponseMessage<>(ResponseMessageErrorCodeEnum.SUCCESS.getCode(), "", true, t);
    }

    public static <T> ResponseMessage<T> error() {
        return error("");
    }

    public static <T> ResponseMessage<T> error(String message) {
        return error(ResponseMessageErrorCodeEnum.ERROR.getCode(), message);
    }

    public static <T> ResponseMessage<T> error(int code, String message) {
        return error(code, message, null);
    }

    public static <T> ResponseMessage<T> error(int code, String message, T t) {
        return new ResponseMessage<>(code, message, false, t);
    }

}